package com.wlw.eye.mvp.presenter

import android.content.Context
import com.wlw.eye.mvp.contract.FindContract
import com.wlw.eye.mvp.model.FindModel
import com.wlw.eye.mvp.model.bean.FindBean
import com.wlw.eye.utils.applyScheduler

class FindPresenter(context: Context?, view: FindContract.View) : FindContract.Presenter {
    var mContext: Context? = null
    var mView: FindContract.View? = null

    init {
        mView = view
        mContext = context
    }

    private val mModel: FindModel by lazy {
        FindModel()
    }

    override fun requestData() {
        val observable = mContext?.let { mModel.loadData(it) }
        observable?.applyScheduler()?.subscribe { beans: MutableList<FindBean> ->
            mView?.setData(beans)
        }

    }

    override fun start() {
        requestData()
    }
}